//
//  HZFindCategoriesData.m
//  app
//
//  Created by 刘华舟 on 15/5/29.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HZFindCategoriesData.h"

@implementation HZFindCategoriesData

+ (instancetype)dataWithDictionary:(NSDictionary *)dict{
    return [[HZFindCategoriesData alloc] initDataWithDictionary:dict];
}
- (instancetype)initDataWithDictionary:(NSDictionary *)dict{
    if (self = [super init]) {
        
        NSMutableArray *towLists = [NSMutableArray array];
        
        for (NSDictionary *subCell in [dict arrayForKey:APIKEY_mall_two_kinds]) {
            HZFindCategoryColCellModel *subModel = [HZFindCategoryColCellModel modelWithDictionary:subCell];
            [towLists addObject:subModel];
        }
        _subCategoryArray = towLists;
        
        NSMutableArray *lists = [NSMutableArray array];
        
        for (NSDictionary *cell in [dict arrayForKey:APIKEY_mall_one_kinds]) {
            HZFindCategoryModel *model = [HZFindCategoryModel modelWithDictionary:cell];
            
            NSMutableArray *subKinds = [NSMutableArray array];
            
            for (HZFindCategoryColCellModel *subModel in _subCategoryArray) {
                if ([model.kindID isEqualToString:subModel.parentID] && subModel.parentID.length > 0) {
                    [subKinds addObject:subModel];
                }
            }
           
            model.levelsArray = subKinds;
            
            [lists addObject:model];
        }
        _columDetailArray = lists;
        
        _currentCategory = [_columDetailArray firstObject];
        
    }
    return self;
}

@end
